<extend  name="Public:iframe" />
<block name="content">
    <form class="layui-form" style="">
        <div class="layui-form-item">
            <label class="layui-form-label">类型名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" value="" required lay-verify="required" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
    </form>
</block>
<block name="foot_script">
    <script>
        $(layui.use(['layer','form','layedit','laydate'], function(){
            var layer = layui.layer,form = layui.form,layedit = layui.layedit;



            form.on('submit(submit)',function (data) {
                $.post('{:U("Article/add_type")}',data.field,function (res) {
                    if (res.code === 1){
                        layer.msg(res.msg,{time:1000},function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(res.msg,{time:1000});
                    }
                });
                return false;
            });

        }));
    </script>
</block>